package com.liws.helloThreadPools.service;

import com.liws.helloThreadPools.utils.FactorialUtils;

import java.util.concurrent.Callable;

/**
 * @author ：liweisheng
 * @date ：2021/12/26 16:31
 * @description：
 */
public class MyTask implements Callable<Long> {

    Long num;

    public MyTask(){

    }

    public MyTask( Long num){
        this.num=num;
    }
    @Override
    public Long call() throws Exception {
        // 模拟耗时操作
        Thread.sleep(1000);
        Long sum=0L;
        for (Long j=1L;j<=num;j++){
            Long aLong = FactorialUtils.countFactorial(j);
            sum+=aLong;
        }
        return sum;
    }
}
